package edu.upf.grupoe.p2ppicture.SearchEngine.implementations;

import edu.upf.grupoe.p2ppicture.SearchEngine.interfaces.GenericMessage;
import java.io.Serializable;
import org.jivesoftware.smack.packet.Message;
/**
 * This class represents a GenericMessage, which is extended by Smack Message class and which is composed by a Header(destiny, from, type of object that carries) and an Object that can be a SearchResultImpl, a UserContentImpl, a SearchProfileImpl or a String class.
 */
public class GenericMessageImpl extends Message implements GenericMessage, Serializable{

    private Object object = null;
    /**
     * This method returns the object of the GenericMessage
     * @return Object
     */
    public Object getObject() {
        return object;
    }
    /**
     * This method sets an object to a GenericMessage object
     * @param object Object
     */
    public void setObject(Object object) {
        this.object = object;
    }
    /**
     * GenericMessage Constructor. The property String and the Object fields have to be related.
     * @param to String
     * @param from String
     * @param property String. It can be SearchResult, SearchProfile, UserContent or Confirmation
     * @param object Object. It can be: SearchResultImpl, SearchProfileImpl, UserContentImpl or String
     */
    public GenericMessageImpl(String to, String from, String property, Object object){
        this.setFrom(from);
        this.setTo(to);
        this.setProperty(property, object);
    }
}
